package com.nobug.run;

import com.nobug.MyClipboard;
import com.nobug.MyRobot;

import java.awt.event.KeyEvent;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 神武自动水帮派 拿水神脚本
 * @author 389561407@qq.com
 * @version 1.0
 * @since 2023-02-04
 */
public class Zidongfa {

    public static void main(String[] args) {
        runMain(30);
    }

    /**
     * 主方法
     */
    public static void runMain(int s) {
        System.out.println("您设置的是每隔8秒发送一个帮派消息");
        System.out.println("现在请将界面切换到神武游戏页面");
        MyRobot.sleep(1000);
        System.out.println("自动发消息将在5秒后启动");
        MyRobot.sleep(5000);
        System.out.println("即将打开记事本,请不用担心，只是解决一个中文显示问题");
        System.out.println("请勿做鼠标键盘操作");
        System.out.println("请勿做鼠标键盘操作");
        System.out.println("请勿做鼠标键盘操作");
        MyRobot.key(KeyEvent.VK_WINDOWS,KeyEvent.VK_R);
        MyRobot.key(KeyEvent.VK_N);
        MyRobot.key(KeyEvent.VK_O);
        MyRobot.key(KeyEvent.VK_T);
        MyRobot.key(KeyEvent.VK_E);
        MyRobot.key(KeyEvent.VK_P);
        MyRobot.key(KeyEvent.VK_A);
        MyRobot.key(KeyEvent.VK_D);
        MyRobot.key(KeyEvent.VK_ENTER);
        MyRobot.key(KeyEvent.VK_ENTER);
        MyRobot.sleep(1000);
        MyRobot.key(KeyEvent.VK_ALT,KeyEvent.VK_TAB);



        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");

        while (true){
            Date date = new Date();
            String format = simpleDateFormat.format(date);
            String data = "现在是绍兴时间:"+format+"#67";
            send(data);
            String sx = getSX();
            send(sx);
            String tg  = getTG();
            send(tg);
            MyRobot.sleep(s*1000);
        }
    }

    private static void send(String data) {
        if(data ==null){
            return;
        }
        MyClipboard.into(data);
        MyRobot.key(KeyEvent.VK_ALT,KeyEvent.VK_TAB);
        MyRobot.key(KeyEvent.VK_CONTROL,KeyEvent.VK_V);
        MyRobot.key(KeyEvent.VK_CONTROL,KeyEvent.VK_A);
        MyRobot.key(KeyEvent.VK_CONTROL,KeyEvent.VK_C);
        MyRobot.key(KeyEvent.VK_ALT,KeyEvent.VK_TAB);
        MyRobot.key(KeyEvent.VK_CONTROL,KeyEvent.VK_V);
        MyRobot.key(KeyEvent.VK_ALT,KeyEvent.VK_3);
        MyRobot.sleep(3000);
    }

    private static String getSX() {
        int i = getMM();
        if(i<30&&i>20){
            return "生肖将在"+(30-i)+"分钟后刷新，请做好准备。#99";
        }else if(i<32&i>=30){
            return "生肖已刷新"+(i-30+1)+"分钟，可能还有，快去找找吧#50";
        }else if(i<35&i>=32) {
            return "生肖已刷新"+(i-30)+"分钟，估计是没有了，下次早做准备#50";
        }

        return null;
    }

    private static String getTG() {
        int i = getMM();
        if(i<3){
            return "天罡已经刷新"+i+"分钟，快去各地找找可能还有机会找到#50";
        }else if(i<=10){
            return "天罡已经刷新"+i+"分钟，没有刷到的早点组队呀。#50";
        }else if(i>55){
            return "天罡将在"+(60-i)+"分钟后刷新，请做好准备。#99";
        }
        return null;
    }

    private static int getMM() {
        return Integer.parseInt(new SimpleDateFormat("mm").format(new Date()));
    }



}
